-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #6767: correctly rehash queries in a migration #7184
Conversation
@@ -18,7 +18,7 @@ def _table_name_from_select_element(elt): | |||
if isinstance(t, Alias): | |||
t = t.original.froms[0] | |||
|
|||
while isinstance(t, _ORMJoin): | |||
while isinstance(t, _ORMJoin) or isinstance(t, Join): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive by fix as otherwise this would generate an error message in the logs when running the migration.
The concept sounds ok, though we'll need someone with a decent understanding of SQLAlchemy and Alembic (not me yet) to do the technical review. 😄 |
If no-one else gets to it sooner, I'll do some testing of this tomorrow against a production instance that was having upgrade issues due to this and verify it works there. 😄 |
@justinclift note that it will likely not fix the issue. This is only half the solution. The other part is #7111. But I'm not sure about the fix there (will soon publish comments). The other option is to update the hash of the query result referenced by latest_query_data_id. Might not be big of a deal on most deployments, but can take time on bigger deployments. |
@justinclift after reviewing it again, the issue with different hash in |
@justinclift did you have a chance to test this? |
It was on today's ToDo list, but other stuff happened. ie: due to a change in IP addressing I found I couldn't access the required VMs from the local co-working place (now fixed), so instead used the time there to get other stuff done. It's on tomorrow's ToDo list now 😉 |
Testing this today. It's taking a bit of time to do the setup, and the testing might run into tomorrow as well (will find out), but it's finally at the top of the ToDo list. 🕺 |
@arikfr This is throwing an error in my testing while doing a version 10.x upgrade to the latest source (with this PR and #7111 cherry-picked on top):
This is happening in a clone of the VM from last time. Want to take a look? 😄 (I'll need to add your IP address to the firewall again though, as I forgot to write it down... 🤦) |
@justinclift I think I fixed it in: 54c3130, but if it persists I can take a look in the VM. |
No worries. I should be good to test that in a few hours. 😄 |
That looks a lot happier:
The While I'm at it, I might as well check some other production Redash databases too, and see if anything shows up with them. Best to catch any weirdness early before other people start trying this in earnest. 😄 That further testing will happen over the coming days, but shouldn't take too much time. Thanks for putting time into this @arikfr. 😄 |
Just tried this out with every production Redash database we're hosting, and no further errors were thrown. 😄 I have not yet checked if the |
Came across something a bit unexpected when prodding this while setting things up to do some more testing. It looks like the rehashing done by database migrations is a bit different to the rehashing when triggered from the command line. Example from database migration
Example from command line
Manually running the rehashing operation a second time reports no hashes changing:
What seems to be happening is the manual rehash from the cli is only reporting when hashes change, and the first time it runs it changes exactly (and only) the hashes which the database migration said might be incorrect. Haven't yet tested how the pieces work in each instance when the corresponding query is used in an embed. Will be doing so today. 😄 |
k, this PR looks good to me now. When testing the embeds they all seem to be happy now, even the queries that had hash warnings appear are working ok. 😄 |
54c3130
to
b0db978
Compare
b0db978
to
a5ae950
Compare
@justinclift thank you for your effort with testing this! The hash is different because We should probably document the need to run rehash if you see this warning (or maybe update the warning to say this?). |
Yeah, updating the warning is probably the right move. That should help minimise the number of support issues people open about it. 😁 |
What type of PR is this?
Description
TBD.
How is this tested?
Related Tickets & Documents
Fixes #6767.